package com.example.attrimirror.data;

import android.content.Context;
import android.widget.Toast;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class CheckinInitializer implements Initializer {
    private final Gson gson;

    public CheckinInitializer() {
        this.gson = new GsonBuilder().setPrettyPrinting().create();
    }

    @Override
    public void initialize(Context context, File dataDir) {
        File checkinFile = new File(dataDir, "checkin.json");
        try {
            if (!checkinFile.exists()) {
                if (!checkinFile.createNewFile()) {
                    Toast.makeText(context, "创建签到数据文件失败", Toast.LENGTH_SHORT).show();
                    return;
                }
                try (FileWriter writer = new FileWriter(checkinFile)) {
                    gson.toJson(new ArrayList<String>(), writer);
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
            Toast.makeText(context, "创建签到数据文件失败: " + e.getMessage(), Toast.LENGTH_SHORT).show();
        }
    }
} 